package com.design.pattern.prototype.deep;


import com.design.pattern.prototype.utils.CopyUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0
 * @author: CRM_SYSTEM
 * @date: 2022/9/15 23:40
 * @Description:
 */
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        User user=new User();
        user.setName("Tom");
        user.setGender("男");
        user.setAge(20);
        user.setWeight(67.301d);
        List<String> hobbies=new ArrayList<>();
        hobbies.add("美术");
        hobbies.add("跑步");
        user.setHobbies(hobbies);

//        User clone = user.deepCloneV2();
//        User clone = CopyUtils.copy(user);
        User clone = CopyUtils.deepCopy(user);
        clone.getHobbies().add("登山");
        System.out.println(user);
        System.out.println(clone);

        System.out.println(clone==user);
        System.out.println(clone.getHobbies()== user.getHobbies());
    }
}
